<!DOCTYPE html>
<!-- saved from url=(0029)http://my.sto.cn/Branch/Index -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8;">
    <title>投诉</title>
    <script src="/admin/js/jquery.min.js"></script>
    <script src="/home/branch/js/jquery.cookie.js"></script>
    <script src="/home/js/city-picker.data.js"></script>
    <script src="/home/branch/js/city-picker.js"></script>

    <script type="text/javascript" src="/home/js/msg.js"></script>

    <link rel="stylesheet" type="text/css" href="/home/branch/css/index.css">
    <link rel="stylesheet" type="text/css" href="/home/branch/css/common.css">
    <link rel="stylesheet" type="text/css" href="/home/branch/css/styles.css">
    <link rel="stylesheet" type="text/css" href="/home/branch/css/city-picker.css">
    <link rel="stylesheet" type="text/css" href="/home/layui/css/layui.css">

    <style>
        .layui-laypage .layui-laypage-curr .layui-laypage-em {
            position: absolute;
            left: -1px;
            top: -1px;
            padding: 1px;
            width: 100%;
            height: 100%;
            background-color: #F08C48;
        }
    </style>
</head>
<body>
<#setting datetime_format="yyyy-MM-dd"/>
<#include "../common/header.ftl">
<#include "../common/top_nav.ftl">

<div class="box" style="min-height:800px;">
    <div id="app">
        <div class="apply-site-container flex">
            <div class="apply-site-main" id="complaintBox" style="width: 700px">
                <section class="apply-site-section">
                    <h3 class="apply-site-title">投诉</h3>
                    <form class="layui-form" id="complaintForm" style="margin: 70px">
                        <div class="layui-form-item">
                            <div class="layui-block">
                                <label class="layui-form-label">订单编号:</label>
                                <div class="layui-input-block">
                                    <input type="text" name="waybillNumber" id="waybillNumber" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-block">
                                <label class="layui-form-label">您的姓名:</label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" id="name" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-block">
                                <label class="layui-form-label">联系方式:</label>
                                <div class="layui-input-block">
                                    <input type="text" name="mobile" id="mobile" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">您的身份:</label>
                            <div class="layui-input-block">
                                <select name="homeUserType" id="homeUserType">
                                    <option value="">----请选择----</option>
                                        <#list homeUserTypeEnum as homeUserType>
                                            <option value="${homeUserType}">${homeUserType.getName()}</option>
                                        </#list>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">投诉内容</label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入投诉内容，最多200字" class="layui-textarea"
                                          name="content" id="content" maxlength="200"></textarea>
                            </div>
                        </div>
                        <footer class="apply-site-footer">
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" id="complaint" style="background-color: #F08C48"
                                            lay-submit
                                            lay-filter="*">立即提交
                                    </button>
                                </div>
                            </div>
                        </footer>
                    </form>
                </section>
            </div>
        </div>
    </div>
</div>
    <#include "../common/footer.ftl"/>

<script type="text/javascript" src="/home/layui/layui.all.js"></script>

<script>

    $("#complaint").click(function () {
        if ($("#waybillNumber").val().trim() == "") {
            errorMsg("订单编号不能为空");
            return false;
        }
        if ($("#name").val() == "") {
            errorMsg("姓名不能为空");
            return false;
        }
        if (!/(^[\u4E00-\u9FA5]+$)|(^[\u4E00-\u9FA5]*·[\u4E00-\u9FA5]*$)/.test($("#name").val())) {
            errorMsg("姓名格式不正确");
            return false;
        }
        if ($("#mobile").val() == "") {
            errorMsg("手机号不能为空");
            return false;
        }
        if (!msg.isPhone($("#mobile").val())) {
            errorMsg("手机号格式不正确");
            return false;
        }
        if ($("#homeUserType").val() == "") {
            errorMsg("身份不能为空");
            return false;
        }
        if ($("#content").val().trim() == "") {
            errorMsg("投诉内容不能为空");
            return false;
        }
        var formData = $("#complaintForm").serialize();
        $.ajax({
            url: "/home/complaint/add",
            type: 'POST',
            data: formData,
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    successMsg("投诉提交成功");
                    setTimeout(function () {
                        window.location.reload();
                    }, 1000);
                } else {
                    errorMsg(data.msg);
                }
            }
        });

    });

    layui.use('form', function () {
        var form = layui.form;
        form.on('submit(*)', function () {
            return false;
        });
    });

</script>
</body>
</html>